/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */
#ifndef PLELF_SECTION_HEADER64_H
#define PLELF_SECTION_HEADER64_H

#include <elf/plelfstddef.h>
#include <elf/plelfsectionheaderenums.h>

namespace PLSDK {

/**
 * Represent a elf 64 bit section header.
 */
class PLELFSectionHeader64 : public PLELFSectionHeaderEnums {
public:
	/**
	 * Constructor.
	 */
	inline PLELFSectionHeader64() {}
	/**
	 * Get the type of the elf section header.
	 *
	 * @return The type.
	 */
	inline PLELFSectionHeader64::SHType type();
	/**
	 * Get the flags from the secton header.
	 *
	 * @return The flags.
	 */
	inline PLELFSectionHeader64::SHFlags flags();
	/**
	 * This member specifies the name of the section. Its value is an index
	 * into the section header string table section giving the location of
	 * a nullterminated string.
	 */
	Elf64_Word sh_name;
	/**
	 * This member categorizes the section’s contents and semantics.
	 */
	Elf64_Word sh_type;
	/**
	 * Sections support 1-bit flags that describe miscellaneous attributes.
	 */
	Elf64_Xword sh_flags;
	/**
	 * If the section will appear in the memory image of a process, this member gives the
	 * address at which the section’s first byte should reside. Otherwise, the member
	 * contains 0.
	 */
	Elf64_Addr sh_addr;
	/**
	 * This member’s value gives the byte offset from the beginning of the file to the first
	 * byte in the section.
	 */
	Elf64_Off  sh_offset;
	/**
	 * This member gives the section’s size in bytes.
	 */
	Elf64_Xword sh_size;
	/**
	 * This member holds a section header table index link, whose interpretation depends
	 * on the section type.
	 */
	Elf64_Word sh_link;
	/**
	 * This member holds extra information, whose interpretation depends on the section
	 * type.
	 */
	Elf64_Word sh_info;
	/**
	 * Some sections have address alignment constraints. For example, if a section holds a
	 * doubleword, the system must ensure doubleword alignment for the entire section.
	 * That is, the value of sh_addr must be congruent to 0, modulo the value of
	 * sh_addralign. Currently, only 0 and positive integral powers of two are allowed.
	 * Values 0 and 1 mean the section has no alignment constraints.
	 */
	Elf64_Xword sh_addralign;
	/**
	 * Some sections hold a table of fixed-size entries, such as a symbol table. For such a section,
	 * this member gives the size in bytes of each entry. The member contains 0 if the
	 * section does not hold a table of fixed-size entries.
	 */
	Elf64_Xword sh_entsize;
} __attribute__((packed));

PLELFSectionHeader64::SHType PLELFSectionHeader64::type() {
	return (PLELFSectionHeader64::SHType)sh_type;
}

PLELFSectionHeader64::SHFlags PLELFSectionHeader64::flags() {
	return PLELFSectionHeader64::SHFlags(sh_flags);
}

}

#endif
